for j in range(1, 10):
    for i in range(1, j + 1):
        # print('{}*{}={:<4}'.format(i, j, i * j), end="")
        print('{}*{}={}\t'.format(i, j, i * j), end="")
    print()  # 外层循环换行
print()

for j in range(9, 0, -1):
    for i in range(1, j + 1):
        print('{}*{}={:<4}'.format(i, j, i * j), end='')
    print()  # 外层循环换行
print()

for j in range(1, 10):
    for i in range(9, 0, -1):
        if i > j:
            # print(' ' * 8, end='')
            print('{:<8}'.format(' '), end='')
        else:
            print('{}*{}={:<4}'.format(i, j, i * j), end='')
    print()  # 外层循环换行
print()

for j in range(9, 0, -1):
    for i in range(9, 0, -1):
        if i > j:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(i, j, i * j), end='')
    print()  # 外层循环换行
print()

i = 1
while i <= 9:
    j = 1
    while j <= i:
        print('{}*{}={:<4}'.format(j, i, j * i), end='')
        j += 1
    print()  # 外层循环换行
    i += 1
print()

i = 9
while i >= 1:
    j = 1
    while j <= i:
        print('{}*{}={:<4}'.format(j, i, j * i), end='')
        j += 1
    print()  # 外层循环换行
    i -= 1
print()

i = 1
while i <= 9:
    j = 9
    while j >= 1:
        if j > i:
            print('{:<8}'.format(' '), end='')
        else:
            print('{}*{}={:<4}'.format(j, i, j * i), end='')
        j -= 1
    print()  # 外层循环换行
    i += 1
print()

i = 9
while i >= 1:
    j = 9
    while j >= 1:
        if j > i:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(j, i, j * i), end='')
        j -= 1
    print()  # 外层循环换行
    i -= 1